package com.juyu.miliao.api.controller;

import com.juyu.miliao.api.service.SpringFestivalActivitiesService;
import com.juyu.miliao.common.domain.Subject;
import com.juyu.miliao.common.exception.ConsumeRuntimeException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * 春节活动
 *
 * @author xuanqicheng
 * @create 2019-25-15:56
 */
@RestController
@RequestMapping("/springFestival")
@CrossOrigin
public class SpringFestivalActivitiesController {


    @Autowired
    private SpringFestivalActivitiesService springFestivalActivitiesService;

    @GetMapping("/{type}")
    public Object getList(Authentication token, @PathVariable("type") String type) {


        if (StringUtils.isEmpty(type)) {
            throw new ConsumeRuntimeException("榜单类型不能为空");
        }

        Subject subject = (Subject) token.getPrincipal();

        return springFestivalActivitiesService.getGoldListByType(subject.getId(), type);
    }
}
